<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm" method="post" enctype="multipart/form-data">
		   <input type="hidden" class="form-control" name="id"  value="${talentsRecommend.id}"/>
		   <input type="hidden" class="form-control" id="demandId" name="demandId"  value="${talentsRecommend.demandId}"/>
		   <input type="hidden" class="form-control" name="talentsId"  value="${talentsRecommend.talentsId}"/>
		   <input type="hidden" class="form-control" name="reportFile"  value="${talentsRecommend.reportFile}"/>
		   <input type="hidden" class="form-control" name="reason"  value="${talentsRecommend.reason}"/>
		    <div class="form-group">
				<label class="col-sm-3 control-label">企业对接人：</label>
				<div class="col-sm-8 form-inline">
				    <select class="form-control" id="docker" name="docker">
				      <option value="">==请选择==</option>
					</select>
					<button type="button" onclick="opencontact();">刷新</button>
					<p class="help-block" style="color: red;">如新增企业联系人，请刷新后选择</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">推荐结果：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="results" name="results" value="${talentsRecommend.results}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">预计到岗时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="arrivalTime" name="arrivalTime"  value="${talentsRecommend.arrivalTime}" onfocus="WdatePicker({minDate:'%y-%M-%d}'})" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="remark" name="remark"  value="${talentsRecommend.remark}"/>
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
	  $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
        	  new Array('results','推荐结果未填写!')
        	)
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/talentsRecommend/update',
                type: 'post',
                dataType: "json",
                success: function (data) {
                    if (data.code == 200) {
                        swal({
                            title: data.message,
                            type: "success",
                            showCancelButton: false,
                            confirmButtonText: "确定",
                            animation: "slide-from-bottom",
                            closeOnConfirm: true
                        }, function () {
                            top.Dialog.close();
                        });
                    } else {
                        swal("错误", data.message, "error");
                    }
                }
            });

        });
    });
    function opencontact(id) {
		if(typeof(id) == "undefined"){
			id = $("#demandId").val();
		}
		var contact = "${talentsRecommend.docker}";
		if(id!=''){
			$.ajax({
	    		url: '<%=contextPath%>/company/getContactBy?demandId='+id,
				type : 'post',
				dataType : "json",
				success : function(data) {
					var htm='<option value="">==请选择==</option>';
					if(data.code==200){
						var result = data.contacts;
						for (var i = 0; i < result.length; i++) {
							if(contact == result[i].contactId){
								htm +='<option value="'+result[i].contactId+'" selected>'+result[i].resume.trueName+'/'+result[i].resume.cellphone+'</option>';
							}else {
								htm +='<option value="'+result[i].contactId+'">'+result[i].resume.trueName+'/'+result[i].resume.cellphone+'</option>';
							}
						}
					}
					$("#docker").html(htm);
				}
	    	});
		}else {
			swal({
    			title:"请选择推荐岗位",
    			text: "2秒后自动关闭。", 
    			timer: 2000, 
			    showConfirmButton: false
    		});
		}
		
	}
</script>
</body>
</html>